package com.xiaogao.common.config.mybatisplus;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.xiaogao.common.config.mybatisplus.interceptor.DataScopeInterceptor;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisPlusConfig {
    @Autowired
    private HttpServletRequest request;

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        // 添加一个数据权限的拦截器
        mybatisPlusInterceptor.addInnerInterceptor(new DataScopeInterceptor(request));
        return mybatisPlusInterceptor;
    }
}
